<%@ page language="java" import="java.util.*,com.hs.auth.model.*,com.hs.core.cache.*,com.hs.dnms.model.*" pageEncoding="utf-8"%>
 <%
   DnmsMagazine obj = (DnmsMagazine)request.getAttribute("obj"); 
   Set disset = obj.getDisset();
   Iterator iter1 = disset.iterator();
   DnmsDisease disobj = null;
   while(iter1.hasNext()){
   		disobj = (DnmsDisease)iter1.next();
   }
     
 
  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="../../include.jsp"%>  
<script language="javascript" type="text/javascript" src="<%=basePath%>common/uploadify/jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript" src="<%=basePath%>common/javascripts/My97DatePicker/WdatePicker.js"></script>
<script language="javascript" type="text/javascript" src="<%=basePath%>common/uploadify/jquery.uploadify.v2.1.4.js"></script>
<script type="text/javascript" src="<%=basePath%>common/uploadify/swfobject.js"></script>
<LINK rel=stylesheet type=text/css href="<%=basePath%>common/uploadify/uploadify.css"/>  
<script src='<%=basePath%>dwr/interface/dataProhelper.js'></script>  

<script language="javascript" type="text/javascript">
function dataPro(id){
	window.location.href="";

}
/**
文件上传
*/
$(document).ready(function()
        {   
            $("#uploadify").uploadify({ 
            'uploader': '<%=basePath%>common/uploadify/uploadify.swf',
	　　		'script': '<%=basePath%>produce/fileSave.do?id=<%=obj==null?"":obj.getId()%>', 
	　　		'cancelImg': '<%=basePath%>common/uploadify/cancel.png', 
	        'queueID':'fileQueue', 
	        'fileDataName':'bookfile',
	        'fileExt': '*.PDF;*.pdf;',
	        'fileDesc':'请选择PDF文件类型',  
        	'wmode': 'transparent', 
        	'auto': false,
       		'multi': true,
       		'simUploadLimit':999,
       		'buttonImg':'<%=path%>/common/uploadify/selectfile.gif',
       		'sizeLimit':9999999999,
        	'onSelect':function(){
        	    
        	    // $("#uploadify").uploadifySettings('script',urlinit);
        	},
        	'onProgress':function(){
        		 _grayWindow(true); 
        	},
        	'onComplete': function (event, queueID, fileObj, response, data)
		     { 
		         var returnstr = response; 
 		         callback4Fileinsert(returnstr);
		     } ,
		     'onError': function(event, queueID, fileObj) {  
					alert("文件上传异常:" + event);  
			 }
        	
　　         });
         });
function uploadfile(){ 
	           $('#uploadify').uploadifyUpload();
	       }
/**
文件上传回调函数
*/	       
var fileid = 0;
function callback4Fileinsert(message){   
     var cellFunctions = [   
          function(item) {   
           	return "<a href=javaScript:viewPdfFile('"+item.id+"')>"+item.fileName+"</a>";
          }, 
          function(item) {  
           	return "<input type='button' onclick=downLoadFile('"+item.id+"') value='下载' class='but_2' />&nbsp;";
          }, 
          function(item) {  
           	return "<input type='button' onclick=deleteFile('"+item.id+"'); value='删除' class='but_2'/>";
          }
      ];    
     var index = message.indexOf("$"); 
     fileid = message.substring(0,index); 
     var rowdata = message.substring(index+1); 
     var data = eval('('+rowdata+')');   
      DWRUtil.addRows("listfile", data, cellFunctions,{
          rowCreator:function(options) { //自定义 tr 的创建行为 
          var trobj = document.createElement("tr");   
          trobj.setAttribute("id","file_"+fileid); 
          return trobj; 
     },cellCreator:function(options) {
	var cell = document.createElement("td"); 
	if(options.cellNum==0) {//表示第一列，以此类推   
	  	cell.width = "80%";
		}else{
		    cell.width = "10%";
	    cell.align="center";
	     
	}
	return cell;
}, escapeHtml:false
     });
    alert('文件上传成功！');  
     _grayWindow(false); 
    }
	       function callback4FileDelete(data){  
	       		var tbody  = document.getElementById("listfile");// tbody 的id
        		var rowobj = document.getElementById("file_"+data); 
        		tbody.removeChild(rowobj);
	       }
	       function deleteFile(fileid){ 
	       		if(confirm("确认要删除该文档吗?")){
	       			dataProhelper.deleteFile(fileid,callback4FileDelete);
	       		} 
	       }	   
	       
/**疾病信息保存*/
function saveDisinfo(id){
 	var disname = document.getElementById("disname").value;
	var disnamen = document.getElementById("disnamen").value;
	if(isNull(disname)){
		alert("请输入现代中医疾病名称！");
		return;
	}
	var istangyao = getRadioValue("istangyao"); 
	var disid = document.getElementById("disid").value; 
	var iszhongchengyao = getCheckBoxValue("iszhongchengyao");
	var isxiyi = getCheckBoxValue("isxiyi");
	var iszhenjiu = getCheckBoxValue("iszhenjiu");
	var istuina = getCheckBoxValue("istuina");
	var isshoushu = getCheckBoxValue("isshoushu"); 
	var curemethod = document.getElementById("curemethod").value;  
	//var doctype = document.getElementById("doctype").value;
	//var doccatagory = document.getElementById("doccatagory").value;
	
	
   		
    var obj = document.getElementsByName("doctype"); 
    var typestr = "";
    for(var i=0;i<obj.length;i++){         
      	if(obj[i].checked){   
          	  typestr+=obj[i].value+",";         
        }         
    }
    if("" == typestr){
    	alert("请选择文档类型！");
    	return;
    }
     var docobj = document.getElementsByName("doccatagory"); 
    var catastr = "";
    for(var j=0;j<docobj.length;j++){         
      	if(docobj[j].checked){   
          	  catastr+=docobj[j].value+",";         
        }         
    }
     if("" == catastr){
    	alert("请选择文献分类！");
    	return;
    }
     $.blockUI({message:'正在处理，请等待...'});

    //setTimeout($.unblockUI,2000);
    
    if(!isNull(disid))
    	dataProhelper.updateDis(disid,disname,disnamen,'0',istangyao,iszhongchengyao,isxiyi,istuina,iszhenjiu,isshoushu,curemethod,callback4addDis);
    else
   		dataProhelper.addDis(id,disname,disnamen,'0',istangyao,iszhongchengyao,isxiyi,istuina,iszhenjiu,isshoushu,curemethod,callback4addDis);
    dataProhelper.saveDocInfo('<%=obj.getId()%>',typestr,catastr);
}

var disid = 0;
function callback4addDis(message){ 
    $.unblockUI(); 
    alert('疾病信息保存成功！');    
    document.getElementById("disid").value = message;
    window.parent.dataframe.frameElement.src = "<%=basePath %>produce/datamain.do?id=<%=obj.getId()%>&disid="+message;
}
 
 function callback4DisDelete(data){    
    //var tbody  = document.getElementById("dislist");// tbody 的id 
    //var rowobj = document.getElementById("dis_"+data);  
    //tbody.removeChild(rowobj);
    alert("疾病信息删除成功");
    window.parent.document.location.replace(window.parent.document.location.href);
    
 }
 function deleteDis(id){ 
    var disnum = document.getElementById("disid").value;
    if('' == disnum){
      alert("疾病信息尚未保存");
      return;
    }
 	if(confirm("确认要删除该疾病信息吗?")){
 			dataProhelper.delDis(id,callback4DisDelete);
 	} 
 }	  
 function downLoadFile(id){
 	window.location.href="<%=basePath%>produce/downloadFile.do?pid="+id;
 
 
 }
 function uploadfile(id){ 
 	openwindow("<%=basePath%>produce/uploadFile.do?id="+id,'600','400',''); 
 }

/**疾病信息保存结束**/	           
</script>
</head>
<body>
<div class="deta_proce">
    <ul>
        <li>数据加工</li> 
    </ul>
    <div>
        <table border="0" cellspacing="0" cellpadding="0"> 
          <caption>
           文献信息
          </caption>
          <tr>
            <td width="20%" nowrap>文献类型：</td> 
            <td width="80%">
            <%out.print(DictCacheUtil.getInst().selectStrCheck("doctype","width:100%",obj.getDocumenttype(),"20",3)); %>
            </td>
           </tr>
           <tr>
            <td width="20%" nowrap>文献分类：</td> 
            <td width="80%">
             <%out.print(DictCacheUtil.getInst().selectStrCheck("doccatagory","width:100%",obj.getDoccatagory()+"","21",3)); %>
             
            </td> 
          </tr> 
        </table>
        <table border="0" cellspacing="0" cellpadding="0"> 
          <caption>
           疾病信息
          </caption>
          <tr>
            <td width="15%" nowrap>现代中医疾病：</td> 
            <td width="35%"><input type="text" name="disname" id="disname" style="width:100%" value="<%=disobj==null?"":disobj.getDiseasename() %>" style="width:99%"/>
            <input type="hidden" name="disid" id="disid" value="<%=disobj==null?"":disobj.getId() %>" style="width:99%"/></td> 
            <td width="15%" nowrap>现代西医疾病：</td> 
            <td width="35%"><input type="text" name="disnamen" id="disnamen" value="<%=StringUtilTool.NULL2Blank(disobj==null?"":disobj.getDiseasenamen()) %>" style="width:99%"/></td> 
          </tr> 
          
          <tr>
             <td width="15%" >
           	    治疗方法
            </td>
            <td width="85%" colspan=3>
           	   <input type=checkbox value=1 name="istangyao" id="istangyao" <%if("1".equals(disobj==null?"":(disobj.getIstangyao()+""))){out.println(" checked");} %>/>汤药治疗&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
           	    <input type=checkbox value=1 name="iszhongchengyao" id="iszhongchengyao" <%if("1".equals(disobj==null?"":(disobj.getIszhongy()+""))){out.println(" checked");} %>/>中成药治疗&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
           	    <input type=checkbox value=1 name="isxiyi" id="isxiyi" <%if("1".equals(disobj==null?"":(disobj.getIswest()+""))){out.println(" checked");} %>/>西医治疗  &nbsp;&nbsp;&nbsp;&nbsp;<br></br>
            	<input type=checkbox value=1 name="iszhenjiu" id="iszhenjiu" <%if("1".equals(disobj==null?"":(disobj.getIszhenjiu()+""))){out.println(" checked");} %>/>针灸治疗&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            	<input type=checkbox value=1 name="istuina" id="istuina" <%if("1".equals(disobj==null?"":(disobj.getIstuina()+""))){out.println(" checked");} %>/>推拿治疗&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            	<input type=checkbox value=1 name="isshoushu" id="isshoushu" <%if("1".equals(disobj==null?"":(disobj.getIsshoushu()+""))){out.println(" checked");} %>/>手术治疗&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </td> 
          </tr> 
          <tr>
           <td width="15%" >
           	    其它治疗方法
            </td> 
            <td colspan=3>
           	    <textarea name="curemethod" id="curemethod" rows=2 style="width:100%;"><%=StringUtilTool.NULL2Blank(disobj==null?"":disobj.getCuremethod()) %></textarea>
            </td>  
          </tr> 
        </table> 
        <table border="0" cellspacing="0" cellpadding="0" class="atta_tab">
          <caption>
          已上传附件
          </caption>
          <tr>
             <th>文件名称</th>
            <th width="10%">下载</th>
            <th width="10%">删除</th>
          </tr>
           <tbody id="listfile">
          <%
             if(null != obj.getFileset() && !(obj.getFileset().isEmpty())){
                   Iterator iter = obj.getFileset().iterator();
                   int i = 0;  
                   while(iter.hasNext()){
          	             DnmsFile fileobj = (DnmsFile)iter.next();
          	             i++; 
          	             Long fileid = fileobj.getId();
          	               
           %>
          <tr id="file_<%=fileid %>">
            <td><a href="javaScript:downLoadFile('<%=fileid %>')"><%=fileobj.getFilename() %></a> </td>
            <td><a href="javascript:onclick=downLoadFile('<%=fileid %>');">下载</a> </td>
            <td><a href="javascript:onclick=deleteFile('<%=fileid %>');">删除</a></td>
          </tr>
          <%}}else{ %> 
          </tbody>
          <%} %> 
           
        </table> 
        <div class="tac">
            <input onclick="saveDisinfo('<%=obj.getId() %>')" type="button" value=" 保存 " class="but_2"/>
            <input onclick="deleteDis('<%=obj.getId() %>')" type="button" value=" 删除 " class="but_2"/>
            <input onclick="uploadfile('<%=obj.getId() %>')" type="button" value=" 原文上传 " class="but_3"/> 
        </div> 
        
    </div>
</div> 
</body>
</html>

